package com.gitee.shardingsphere.controller;

import com.gitee.shardingsphere.common.entity.Order;
import com.gitee.shardingsphere.service.IOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 开发人员   YooLin1c
 * 编写日期   2018/6/21
 * 联系邮箱   401664157@qq.com
 * 作用描述
 */
@RestController
@RequestMapping("/orders")
public class OrderController {
    @Autowired
    private IOrderService orderService;

    @GetMapping
    public List<Order> getOrderList() {
        return orderService.getOrderList();
    }

    @PostMapping
    public boolean makeOrder(@RequestBody Order order) {
        return orderService.order(order);
    }

    @DeleteMapping("/{orderId}")
    public boolean cancelOrder(@PathVariable Long orderId) {
        return orderService.cancel(orderId);
    }
}
